<?php
class HomeLatestOffersJobs extends CWidget
{
	public $postParams=array();
	public $config=array();
	
	public function run()
  	{?>

<script type="text/javascript" src="<?php echo ApplicationConfig::app()->params['theme']['jsUrl']?>jquery.tools.min.js"></script>

<div class="pt15 pb15">
   <div class="offer_block shadow fl"> 
   	<div class="title_offer pb20 pt20">Latest<span class="helv_neue_thin">Offers</span><span class="helv_neue_thin fnt16 brown"> this month</span></div>
        <?php $offers = Offer::getList("LATEST-OFFERS", array());
       		if (!empty($offers)){
       			foreach ($offers as $offer){
       				
       			$brand = Vendor::model()->getModel("VENDOR-ID",array('vendorID'=>$offer->vendorID));
       			$tooltiphtml = "<div class='tooltip".$offer->offerID."'><table style=' color:black;padding:5px; -moz-border-radius:5px; width:300px'>
       								<tr>
       									<td style='vertical-align:top; padding-top:20px;padding-left:15px;padding-right:25px;'> <img src='".ApplicationConfig::getImageUrl('VENDOR-IMAGES-THUMB', array('file_name'=>$brand->vendor_logo_thumb))."' style='height: 80px;width: 80px;margin-left: -10px;margin-top: -20px;'/> 
       									<br/><br/>
       									<div class='fl' style='line-height:20px;'>
						                	 <span class='helv_black price_amount'>". $offer->offer_value_percentage."%</span>
						                    <div class='cl'></div>
						                    <span class='helv_light fnt11'>DISCOUNT</span>
						                </div>
       									
       									</td>
       									<td></td>
       									<td><h2 style='margin-bottom:-15px;'>".$brand->vendor_name."</h2><br/><span class='gr fnt12'>".$brand->vendor_description."</span><br/><br/>
       									<b>Deal:</b> <span class='gr fnt12'>".$offer->offer_title."</span><br/>
       									<b>Description: </b><span class='gr fnt12'>".$offer->offer_detail."</span><br/><br/>
       									<b>Location: </b><span class='gr fnt12'>".City::model()->getModel("BY-ID", array('id'=>$offer->offer_redeem_cityID))->city_name."</span><br/>
       									<b>Valid: </b><span class='gr fnt12'>".date("d M, Y",strtotime($offer->offer_expiry_date))."</span><br/><br/>
       									<h2 style='background:#c24c26;text-align:center;border-radius:3px;width:140px;height:30px;line-height:30px;color:white;'> ".$offer->offer_redeem_point." YC CASH</h2>
       									</td>
       								</tr>
       							</table></div>";
       			echo $tooltiphtml;
       			
       	?>  
       	<script type="text/javascript">
       	$(document).ready(function() {
        $("tooltip<?php echo $offer->offerID;?>").tooltip({
            // use div.tooltip as our tooltip
            tip: '.tooltip<?php echo $offer->offerID;?>',
   
            // use the fade effect instead of the default
            effect: 'fade',
   
            // make fadeOutSpeed similar to the browser's default
            fadeOutSpeed: 100,
   
            // the time before the tooltip is shown
            predelay: 400,
   
            // tweak the position
            position: "bottom right",
            offset: [-50, -80]
        });
        });
       	</script>
	       	<style>
	       	.tooltip<?php echo $offer->offerID;?> {
			    display:none;
			    background-color:#ffa;
			    border:1px solid #cc9;
			    padding:3px;
			    font-size:13px;
			    -moz-box-shadow: 2px 2px 11px #666;
			    -webkit-box-shadow: 2px 2px 11px #666;
			}
	       	</style>
        <div class="offer_list pb15" id="<?php echo "offer".$offer->offerID;?>">
        	<div class="y_ball fl" style="color: black"><img src="<?php echo ApplicationConfig::getImageUrl('VENDOR-IMAGES-THUMB', array('file_name'=>$brand->vendor_logo_thumb));?>" style="height: 70px;width: 70px;margin-left: -10px;margin-top: -20px;"/><div class="b_name"><?php  $brand->vendor_name." ".$offer->offer_title;?></div><div class="cl"></div><div class="helv_world fnt10"></div></div>
            <div class="fl ml10 offer_info">
            	<div class="fl" style=" line-height:20px;">
                	 <span class="helv_black price_amount"> <?php echo $offer->offer_value_percentage;?>%</span>
                    <div class="cl"></div>
                    <span class="helv_light fnt11">DISCOUNT</span>
                </div>
                <div class="fr">
					<a class="add" href="#"></a>
					<div class="cl pt10"></div>
					<div class="fr">
					<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script>
					<a class="facebook" href="http://www.facebook.com/share.php?u=<?php echo Yii::app()->request->requestUri;?>" onclick="return fbs_click()" target="_blank"></a>
					<a  class="twitter" href="http://twitter.com/home?status= Currentlyreading <?php echo Yii::app()->getBaseUrl(true)."".Yii::app()->request->requestUri; ?>" title="Click to share this post on Twitter"  target="_blank"></a>
					<a class='email' href='mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20YouthConnect&body=<?php echo "YouthConnect ".Yii::app()->getBaseUrl(true)."".Yii::app()->request->requestUri; ?>' title='YouthConnect Email to a friend/colleague' ></a>
					</div>
				</div>
                <div class="cl"></div>
                <div style="line-height:12px;" class="helv_light"><a class="gr" href="#">View Details</a> <!--<span class="gr">| </span> -->
				<!--<span class="re"><strong>Valid</strong> :25, March 2012</span>--> 
				</div>
            </div>
            <div class="cl"></div>
       </div>
      		<?php }if (count($offers)>4){?>
        see more
        <?php }?>
        <?php }else{ echo "NO latest Offer found";}?>
   </div>
   
   <div class="offer_block shadow fr">
   	<div class="title_offer pb20 pt20">Jobs<span class="helv_neue_thin">Opportunities</span></div>

       	       	<?php $jobs = Job::getList("LATEST-JOBS", array());
       		if (!empty($jobs)){
       			foreach ($jobs as $job){
       			$brand = Vendor::model()->getModel("VENDOR-ID",array('vendorID'=>$job->vendorID));
       			$tooltiphtml = "<table style=' color:black;padding:5px; -moz-border-radius:5px; width:300px'>
       								<tr>
       									<td style='vertical-align:top; padding-top:20px;padding-left:15px;padding-right:25px;'> <img src='".ApplicationConfig::getImageUrl('VENDOR-IMAGES-THUMB', array('file_name'=>$brand->vendor_logo_thumb))."' style='height: 80px;width: 80px;margin-left: -10px;margin-top: -20px;'/> </td>
       									<td></td>
       									<td><h2 style='margin-bottom:-15px;'>".$job->job_title."</h2><br/><span class='gr fnt12'>".$job->job_description."</span>
       									<b>Type:</b> <span class='gr fnt12'>".ApplicationConfig::app()->params['job_params']['type'][$job->job_type]."</span><br/>
       									<b>Skills: </b><span class='gr fnt12'>".$job->skill."</span><br/><br/>
       									<b>Location: </b><span class='gr fnt12'>".City::model()->getModel("BY-ID", array('id'=>$job->job_location_cityID))->city_name."</span><br/>
       									<b>Salary: </b><span class='gr fnt12'>".$job->salary." Per ".ApplicationConfig::app()->params['job_params']['salary_specification'][$job->salary_spec]."</span><br/>
       									<b>Posted On: </b><span class='gr fnt12'>".date("d M, Y",strtotime($job->created))."</span><br/><br/>
       									</td>
       								</tr>
       							</table>"
       	?>
      <div class="offer_list pb15"  title="<?php echo $tooltiphtml?>">
        	<div class="y_ball fl"><a href="<?php echo ApplicationConfig::getURL("", "site", "brands",array('id'=>$brand->vendorID));?>"><img src="<?php echo ApplicationConfig::getImageUrl('VENDOR-IMAGES-THUMB', array('file_name'=>$brand->vendor_logo_thumb));?>" style="height: 70px;width: 70px;margin-left: -10px;margin-top: -20px;"/><div class="b_name"><?php  $brand->vendor_name?></div><div class="cl"></div></a></div>
            <div class="fr offer_info">
            	<div class="fl" style=" line-height:20px;">
                	<!--<span class="helv_neue_thin price_unit">Rs</span>--> <span class="helv_black price_amount"><?php echo $job->salary;?>/-</span>
                    <div class="cl"></div>
                    <span class="helv_light fnt12">PER <?php echo ApplicationConfig::app()->params['job_params']['salary_specification'][$job->salary_spec];?></span>
                    
                    <div style="line-height:12px;" class="helv_light"><span class="gr fnt12" style="position: absolute;width: 150px;">Position : <?php echo $job->position?></span></div>
                    
                </div>
                <div class="fr">
                	<?php
                	if (ApplicationSessions::run()->read('userID')!=""){
                	$jobApp = JobApplication::model()->getModel("JOB-APPLICANT-ID", array('jobID'=>$job->jobID,'applicantID'=>ApplicationSessions::run()->read('userID'),'vendorID'=>$brand->vendorID));
                	if (empty($jobApp))
                	{ 	
						echo "<div id='applydiv$job->jobID'>";
							echo CHtml::ajaxButton(
								'',
								ApplicationConfig::getURL("","myOffer","jobApplication",array('jobID'=>$job->jobID,'userID'=>ApplicationSessions::run()->read('userID'),'vendorID'=>$brand->vendorID)),
								array('update'=>'#applydiv'.$job->jobID),
								array('id'=>'apply'.$job->jobID,'class'=>'apply_btn fr')
							);
						echo "</div>";
                	}
                	else 
                	{
                		echo "<div id='applydiv$job->jobID' style='width: 65px;height:24px;color: white; font-weight:bolder;background:#828282;border-radius: 10px;'> <span style='margin-left:8px;line-height:22px;'>Applied</span></div>";
                	}
                	}
                	else 
                	{
                		echo "<input type='button' class='apply_btn fr' onclick='checkLogin()'>";
                	}
						?>
                <div class="cl pt10"></div>
                	<div class="fr" style="margin-top: -2px;">
                	<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script>
                	<a class="inbtn" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php  echo Yii::app()->getBaseUrl(true)."".Yii::app()->request->requestUri; ?>&title=<?php echo "YouthConnect".Yii::app()->getBaseUrl(true)."".Yii::app()->request->requestUri; ?>&source=<?php  echo Yii::app()->getBaseUrl(true)."".Yii::app()->request->requestUri;?>" target="_blank"></a>
					<a class="facebook" href="http://www.facebook.com/share.php?u=<?php echo Yii::app()->request->requestUri;?>" onclick="return fbs_click()" target="_blank"></a>
					<a  class="twitter" href="http://twitter.com/home?status= Currentlyreading <?php echo Yii::app()->getBaseUrl(true)."".Yii::app()->request->requestUri; ?>" title="Click to share this post on Twitter"  target="_blank"></a>
                	<a class='email' href='mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20YouthConnect&body=<?php echo "YouthConnect ".Yii::app()->getBaseUrl(true)."".Yii::app()->request->requestUri; ?>' title='YouthConnect Email to a friend/colleague' ></a>
					
                	</div>
                </div>                
            </div>
            <div class="cl"></div>
        </div>
           		<?php } if (count($jobs)>4){?>
        <a href="<?php echo ApplicationConfig::getURL("", "site", "job");?>">See more</a>
        <?php }?>
        <?php }else{ echo "NO latest jobs found";}?>     

        
   </div>
    <div class="cl"></div>

</div>
<script>
function checkLogin()
{
	$('#aaa').trigger('click');
	$('#LoginForm_username').val("");
	$('#LoginForm_username').focus();
}
</script>
  		
  	<?php }
}
?>  
 